import {AxiosInstance} from "@/types";
import Axios from './core/Axios'
import {extend} from "@/utils";

function createInstance(): AxiosInstance {
    const context = new Axios();
    //request内部方法会访问this,需要绑定context
    const instance = Axios.prototype.request.bind(context)
    extend(instance, context);
    //强制断言
    return instance as AxiosInstance;
}

const axios = createInstance();
export default axios;